home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / UGPRG.ZIP / VGA-MISC / VBE20.DOC < prev    next >
Text File  |  1995-02-08  |  70KB  |  1,368 lines

  1.  
  2.  
  3.   Video Electronics Standards Association               VBE/Core 2.0 Standard
  4.   2150 North First Street, Suite 440
  5.   San Jose, CA 95131-2029              
  6.   Phone: (408) 435-0333
  7.   FAX: (408) 435-8225
  8.  
  9.  
  10.                           VESA BIOS EXTENSION (VBE)
  11.                               Core Functions
  12.  
  13.                                Version: 2.0
  14.  
  15.  
  16.  
  17.  
  18.  
  19.      NOTE: This is _NOT_ an official version of the VBE/Core 2.0 standard,
  20.            but is provided as is by SciTech Software until the official
  21.            specification is made available electronically. This document
  22.            contains a summary of the important portions of the standard
  23.            related to developing working code for VBE 2.0.
  24.  
  25.            For more information on the official specification, please
  26.            contact VESA at the address listed above.
  27.  
  28.  
  29.  
  30.  
  31.      1.    Introduction
  32.  
  33.      This document contains the VESA BIOS Extension (VBE) specification for
  34.      standard software access to graphics display controllers that support
  35.      resolutions, color depths, and frame buffer organizations beyond the
  36.      VGA hardware standard.  It is intended for use by both applications
  37.      programmers and system software developers.
  38.  
  39.      System software developers may use this document to supplement the
  40.      System and INT 10h ROM BIOS functions to provide the VBE services.
  41.      Application developers can use this document as a guide to programming
  42.      all VBE compatible devices.
  43.  
  44.      To understand the VBE specification, some knowledge of 80x86 assembly
  45.      language and the VGA hardware registers may be required.  However,
  46.      the services described in this specification may be called from any
  47.      high-level programming language that provides a mechanism for
  48.      generating software interrupts with the 80x86 registers set to user-
  49.      specified values.
  50.  
  51.      In this specification, 'VBE' and 'VBE 2.0' are synonymous with 'VBE
  52.      Core Functions version 2.0'.
  53.  
  54.  
  55.      1.1. Scope of the VBE Standard
  56.  
  57.      The primary purpose of the VESA VBE  is to provide standard software
  58.      support for the many unique implementations of Super VGA (SVGA)
  59.      graphics controllers on the PC platform that provide features beyond
  60.      the original VGA hardware standard.  This is to provide a feasible
  61.      mechanism by which application developers can take advantage of this
  62.      nonstandard hardware in graphics applications.
  63.  
  64.      The VBE specification offers an extensible software foundation which
  65.      allows it to evolve as display and audio devices evolve over time,
  66.      without sacrificing backward software compatibility with older
  67.      implementations.  New application software should be able to work with
  68.      older hardware, and application software that has already shipped
  69.      should work correctly on new hardware devices.
  70.  
  71.      VBE services provide standard access to all resolutions and color
  72.      depths provided on the display controller, and report the availability
  73.      and details of all supported configurations to the application as
  74.      necessary.
  75.  
  76.      VBE implementations facilitate the field support of audio and display
  77.      hardware by providing the application software with the manufacturer's
  78.      name and the product identification of the display hardware.
  79.  
  80.      Since graphics controller services on the PC are typically implemented
  81.      in ROM, the VBE services are defined so that they should be
  82.      implemented within the standard VGA ROM.  When ROM implementations of
  83.      VBE are not possible, or when field software upgrades to the onboard
  84.      ROM are necessary, the VBE implementation may be also offered as a
  85.      device driver or DOS Terminate & Stay Resident (TSR) program.
  86.  
  87.      The standard VBE functions may be supplemented by OEM's as necessary
  88.      to support custom or proprietary functions unique to the manufacturer.
  89.      This mechanism enables the OEM to establish functions that may be
  90.      standard to the product line, or provide access to special hardware
  91.      enhancements.
  92.  
  93.      Although previous VBE standards assumed that the underlying graphics
  94.      architecture was a VGA device, the display services described by VBE
  95.      2.0 can be implemented on any frame buffer oriented graphics device.
  96.  
  97.      The majority of VBE services facilitate the setup and configuration of
  98.      the hardware, allowing applications high performance, direct access to
  99.      the configured device at runtime.  To further improve the performance
  100.      of flat frame buffer display devices in extended resolutions, VBE 2.0
  101.      provides new memory models that do not require the traditional frame
  102.      buffer "banking" mechanisms.
  103.  
  104.      VBE is expected to work on all 80x86 platforms, in real and protected
  105.      modes.
  106.  
  107.      Since some modern display devices are designed without any VGA
  108.      support, two display controllers may be present in the system.  One
  109.      display controller would be used for VGA compatibility, and the other
  110.      used for graphic extensions to the basic VGA modes, resolutions, and
  111.      frame buffer models.  Therefore, VBE must be able offer the
  112.      application automatic access to the appropriate device based on the
  113.      mode or resolution that is requested by the application.
  114.  
  115.      Currently beyond the scope of the VBE specification is the handling of
  116.      hardware configuration and installation issues.  It was originally
  117.      considered to become part of VBE 2.0, however we have deferred the
  118.      issues to the Graphics Configuration Supplemental Specification.  In
  119.      addition, it is also possible for an OEM to define their own
  120.      extensions using the OEM Supplemental Specification if required.
  121.  
  122.  
  123.      1.2. Backgrounder
  124.                 1
  125.      The IBM VGA  has become a de facto standard in the PC graphics world.
  126.      A multitude of different VGA offerings exist in the marketplace, each
  127.      one providing BIOS or register compatibility with the IBM VGA. More
  128.      and more of these VGA compatible products implement various supersets
  129.      of the VGA standard. These extensions range from higher resolutions
  130.      and more colors to improved performance and even some graphics
  131.      processing capabilities. Intense competition has dramatically improved
  132.      the price/performance ratio, to the benefit of the end user.
  133.  
  134.      However, several serious problems face a software developer who
  135.      intends to take advantage of these "Super VGA"  environments. Because
  136.      there is no standard hardware implementation, the developer is faced
  137.      with widely disparate Super VGA hardware architecture. Lacking a
  138.      common software interface, designing applications for these
  139.      environments is costly and technically difficult. Except for
  140.      applications supported by OEM-specific display drivers, very few
  141.      software packages can take advantage of the power and capabilities of
  142.      Super VGA products.
  143.  
  144.      The VBE standard was originally conceived to enable the development of
  145.      applications that wished to take advantage of display resolutions and
  146.      color depths beyond the VGA definition.  The need for an application
  147.      or software standard was recognized by the developers of graphic
  148.      hardware to encourage the use and acceptance of their rapidly
  149.      advancing product families.  It became obvious that the majority of
  150.      software application developers did not have the resources to develop
  151.      and support custom device level software for the hundreds of display
  152.      boards on the market.  Therefore the rich new features of these
  153.      display devices were not being used outside of the relatively small
  154.      CAD market, and only then after considerable effort.
  155.  
  156.      Indeed, the need for a standard for SVGA display adapters became so
  157.      important that the VESA organization was formed to seek out a
  158.      solution.  The original VBE standard was devised and agreed upon by
  159.      each of the active display controller manufacturers, and has since
  160.      been adopted by DOS application developers to enable use of non-VGA
  161.      extended display modes.
  162.  
  163.      As time went along VBE 1.1 was created to add more video modes and
  164.      increased logical line length/double buffering support.  VBE 1.2 was
  165.      created to add modes and also added high color RAMDAC support.
  166.  
  167.      In the three years since VBE 1.2 was approved we have seen the
  168.      standard become widely accepted and many successful programs have
  169.      embraced VBE.  However, it has become obvious that the need for a more
  170.      robust and extensible standard exists.  Early extensions to the VGA
  171.      standard continued using all of the original VGA I/O ports and frame
  172.      buffer address to communicate with the controller hardware.  As we've
  173.      seen, the supported resolutions and color depths have grown,
  174.      intelligent controllers with BITBLT and LineDraw Functions have become
  175.      common, and new flat frame buffer memory models have appeared along
  176.      with display controllers that are not based on VGA in any way.  VBE
  177.      2.0 and future extensions will support non-VGA based controllers with
  178.      new functions for reading and writing the palette and for access to
  179.      the flat frame buffer models.
  180.  
  181.      VBE 2.0, as designed, offers the extensibility and the robustness that
  182.      was lacking in the previous specifications, while at the same time
  183.      offering backwards compatibility.
  184.  
  185.      In the future, we see the need for adding supplemental specifications
  186.      for issues like Multimedia; Advanced Graphics Functions; and "Plug and
  187.      Play" features.
  188.  
  189.      2.VBE Overview
  190.  
  191.      This chapter outlines the various features and limitations of the VBE
  192.      standard.
  193.  
  194.  
  195.      2.1. VBE  Features
  196.  
  197.        Standard application interface to Graphics Controllers (SVGA
  198.        Devices)
  199.        Standard method of identifying products and manufacturers.
  200.        Provision for OEM extensions through Sub-function 14h
  201.        Simple protected mode interface.
  202.        Extensible interface through supplemental specifications.
  203.  
  204.  
  205.      2.2. VBE Affected Devices
  206.  
  207.      All frame buffer-based devices in the IBM PC platform (with the
  208.      exception of Hercules, Monochrome (MDA), CGA and EGA devices) are
  209.      suitable for use within the VBE standard to enable access to the
  210.      device by VBE-compliant applications.
  211.  
  212.  
  213.      2.3. Providing Vendor Information
  214.  
  215.      The VGA specification does not provide a standard mechanism to
  216.      determine what graphic hardware it is running on. Only by knowing OEM-
  217.      specific features can an application determine the presence of a
  218.      particular graphics controller or display board. This often involves
  219.      reading and testing registers located at I/O addresses unique to each
  220.      OEM. By not knowing what hardware an application is running on, few,
  221.      if any, of the extended features of the underlying hardware can be
  222.      used.
  223.  
  224.      The VESA BIOS Extension provides several functions to return
  225.      information about the graphics environment. These functions return
  226.      system level information as well as graphics mode specific details.
  227.      Function 00h returns general system level information, including an
  228.      OEM identification string. The function also returns a pointer to the
  229.      supported VBE and OEM modes. Function 01h may be used by the
  230.      application to obtain additional information about each supported
  231.      mode. Function 03h returns the current VBE mode.
  232.  
  233.      3.VBE Mode Numbers
  234.  
  235.      Standard VGA mode numbers are 7 bits wide and presently range from 00h
  236.      to 13h. OEMs have defined extended display modes in the range 14h to
  237.      7Fh. Values in the range 80h to FFh cannot be used, since VGA BIOS
  238.      Function 00h (Set video mode) interprets bit 7 as a flag to clear or
  239.      preserve display memory.
  240.  
  241.      Due to the limitations of 7 bit mode numbers, the optional VBE mode
  242.      numbers are 14 bits wide. To initialize a VBE mode, the mode number is
  243.      passed in the BX register to VBE Function 02h (Set VBE mode).
  244.  
  245.      The format of VBE mode numbers is as follows:
  246.  
  247.           D0-D8     =    Mode number
  248.                          If D8 == 0, this is not a VESA defined mode
  249.                          If D8 == 1, this is a VESA defined mode
  250.           D9-D13    =    Reserved by VESA for future expansion (= 0)
  251.           D14       =    Linear/Flat Frame Buffer Select
  252.                          If D14 == 0, Use VGA Frame Buffer
  253.                          If D14 == 1, Use Linear/Flat Frame Buffer
  254.           D15       =    Preserve Display Memory Select
  255.                          If D15 == 0, Clear display memory
  256.                          If D14 == 1, Preserve display memory
  257.  
  258.      Thus, VBE mode numbers begin at 100h. This mode numbering scheme
  259.      implements standard 7-bit mode numbers for OEM-defined modes.
  260.      Standard VGA modes may be initialized through VBE Function 02h (Set
  261.      VBE mode) simply by placing the mode number in BL and clearing the
  262.      upper byte (BH). 7-bit OEM-defined display modes may be initialized in
  263.      the same way.  Note that modes may only be set if the mode exists in
  264.      the Video Mode List returned in Function 0.
  265.  
  266.      Note: Starting with VBE version 2.0 VESA will no longer define new
  267.      VESA mode numbers and it will not longer be mandatory to support these
  268.      old mode numbers.  However, it is highly recommended that BIOS
  269.      implementations continue to support these mode numbers for
  270.      compatibility with old software.  VBE 2.0-aware applications should
  271.      follow the guidelines in Appendix 5 - Application Programming
  272.      Considerations - for setting a desired mode.
  273.  
  274.      Note:  Mode 81FFh is a special mode designed to preserve the current
  275.      memory contents and to give access to the entire video memory.  This
  276.      mode is especially useful for saving the entire video memory contents
  277.      before going into a state that could lose the contents (e.g. set this
  278.      mode to gain access to all video memory to save it before going into a
  279.      volatile power down state).  This mode is required because the entire
  280.      video memory contents are not always accessible in every mode.  It is
  281.      recommended that this mode be packed pixel in format, and a
  282.      ModeInfoBlock must be defined for it.  Look in the ModeInfoBlock to
  283.      determine if paging is required and how paging is supported if it is.
  284.      Also note that there are no implied resolutions or timings associated
  285.      with this mode.
  286.  
  287.      Note:  Future display resolutions will be defined by VESA display
  288.      vendors.  The color depths will not be specified and new mode numbers
  289.      will not be assigned for these resolutions.  For example, if the VESA
  290.  
  291.      display vendors define 1600x1200 as a VESA resolution, application
  292.      developers should target their display resolution for 1600x1200 rather
  293.      than choosing an arbitrary resolution like 1550x1190.  The VBE
  294.      implementation should be queried to get the available resolutions and
  295.      color depths and the application should be flexible enough to work
  296.      with this list.  Appendix 5 gives a detailed summary of the way an
  297.      application should go about selecting and setting modes.
  298.  
  299.      4.VBE Functions
  300.  
  301.      This chapter describes in detail each of the functions defined by the
  302.      VBE standard.  VBE functions are called using the INT 10h interrupt
  303.      vector, passing arguments in the 80X86 registers.  The INT 10h
  304.      interrupt handler first determines if a VBE function has been
  305.      requested, and if so, processes that request.  Otherwise control is
  306.      passed to the standard VGA BIOS for completion.
  307.  
  308.      All VBE functions are called with the AH register set to 4Fh to
  309.      distinguish them from the standard VGA BIOS functions.  The AL
  310.      register is used to indicate which VBE function is to be performed.
  311.      For supplemental or extended functionality the BL register is used
  312.      when appropriate to indicate a specific sub-function.
  313.  
  314.      Functions 00-0Fh have been reserved for Standard VBE function numbers;
  315.      Functions 10-FFh are reserved for VBE Supplemental Specifications.
  316.  
  317.      In addition to the INT 10h interface, a Protected Mode Interface is
  318.      available and is described below.
  319.  
  320.  
  321.      4.1. VBE Return Status
  322.  
  323.      The AX register is used to indicate the completion status upon return
  324.      from VBE functions.  If VBE support for the specified function is
  325.      available, the 4Fh value passed in the AH register on entry is
  326.      returned in the AL register.  If the VBE function completed
  327.      successfully, 00h is returned in the AH register.  Otherwise the AH
  328.      register is set to indicate the nature of the failure.
  329.  
  330.      VBE RETURN STATUS
  331.  
  332.           AL ==     4Fh: Function is supported
  333.           AL !=     4Fh: Function is not supported
  334.           AH ==     00h: Function call successful
  335.           AH ==     01h: Function call failed
  336.           AH ==     02h: Software supports this function, but the hardware
  337.                          does not
  338.           AH ==     03h: Function call invalid in current video mode
  339.  
  340.      Note: Applications should treat any non-zero value in the AH register
  341.      as a general failure condition as later versions of the VBE may define
  342.      additional error codes.
  343.  
  344.  
  345.      4.2. Protected Mode considerations
  346.  
  347.      VBE services may be called directly from 32-bit Protected mode only.
  348.  
  349.      For 32 bit protected mode, 2 selector/segment descriptors for 32-bit
  350.      code and the data segment are needed. These will be allocated and
  351.      initialized by the caller. The segment limit fields will be set to
  352.      64k. These selectors may either be in the GDT or LDT, but must be
  353.      valid whenever the VBE is called in protected mode. The caller must
  354.      supply a stack large enough for use by VBE and by potential interrupt
  355.      handlers. The caller's stack will be active if or when interrupts are
  356.      enabled in the VBE routine, since the VBE will not switch stacks when
  357.      interrupts are enabled, including NMI interrupts. The 32-bit VBE
  358.      interface requires a 32-bit stack.
  359.  
  360.      When the VBE services are called, the current I/O permission bit map
  361.      must allow access to the I/O ports that the VBE may need to access.
  362.      This can be found in the Sub-table (Ports and Memory) returned by VBE
  363.      Function 0Ah.
  364.  
  365.      To summarize, it is the calling application's responsibility to ensure
  366.      to that it has the appropriate I/O and memory privileges, a large
  367.      enough stack and appropriate selectors allocated.  It is also the
  368.      calling application's responsibility to preserve registers if it needs
  369.      them.
  370.  
  371.      4.3. Function 00h - Return VBE Controller Information
  372.  
  373.      This required function returns the capabilities of the display
  374.      controller, the revision level of the VBE implementation, and vendor
  375.      specific information to assist in supporting all display controllers
  376.      in the field.
  377.  
  378.      The purpose of this function is to provide information to the calling
  379.      program about the general capabilities of the installed VBE software
  380.      and hardware. This function fills an information block structure at
  381.      the address specified by the caller. The VbeInfoBlock information
  382.      block size is 256 bytes for VBE 1.x, and 512 bytes for VBE 2.0.
  383.  
  384.      Input:    AX   = 4F00h  Return VBE Controller Information
  385.             ES:DI   =        Pointer to buffer in which to place
  386.                              VbeInfoBlock structure
  387.                              (VbeSignature should be set to 'VBE2' when
  388.                              function is called to indicate VBE 2.0
  389.                              information is desired and the information
  390.                              block is 512 bytes in size.)
  391.  
  392.      Output:   AX   =         VBE Return Status  
  393.  
  394.      Note: All other registers are preserved.
  395.  
  396.      The information block has the following structure:
  397.  
  398.      VbeInfoBlock struc
  399.      VbeSignature        db   'VESA'    ; VBE Signature
  400.      VbeVersion          dw   0200h     ; VBE Version
  401.      OemStringPtr        dd   ?         ; Pointer to OEM String
  402.      Capabilities        db   4 dup (?) ; Capabilities of graphics cont.
  403.      VideoModePtr        dd   ?         ; Pointer to Video Mode List
  404.      TotalMemory         dw   ?         ; Number of 64kb memory blocks
  405.                                         ; Added for VBE 2.0
  406.      OemSoftwareRev      dw   ?         ; VBE implementation Software revision
  407.      OemVendorNamePtr    dd   ?         ; Pointer to Vendor Name String
  408.      OemProductNamePtr   dd   ?         ; Pointer to Product Name String
  409.      OemProductRevPtr    dd   ?         ; Pointer to Product Revision String
  410.      Reserved            db   222 dup (?); Reserved for VBE implementation
  411.                                         ; scratch area
  412.      OemData             db   256 dup (?); Data Area for OEM Strings
  413.      VbeInfoBlock ends
  414.  
  415.      Note: All data in this structure is subject to change by the VBE
  416.      implementation when VBE Function 00h is called.  Therefore, it should
  417.      not be used by the application to store data of any kind.
  418.  
  419.      Description of the VbeInfoBlock structure fields:
  420.  
  421.      The VbeSignature field is filled with the ASCII characters 'VESA' by
  422.      the VBE implementation.  VBE 2.0 applications should preset this field
  423.      with the ASCII characters 'VBE2' to indicate to the VBE implementation
  424.      that the VBE 2.0 extended information is desired, and the VbeInfoBlock
  425.      is 512 bytes in size.  Upon return from VBE Function 00h, this field
  426.      should always be set to 'VESA' by the VBE implementation.
  427.  
  428.      The VbeVersion is a BCD value which specifies what level of the VBE
  429.      standard is implemented in the software. The higher byte specifies the
  430.      major version number. The lower byte specifies the minor version
  431.      number.
  432.  
  433.      Note:  The BCD value for VBE 2.0 is 0200h and the BCD value for VBE
  434.      1.2 is 0102h. In the past we have had some applications
  435.      misinterpreting these BCD values.  For example, BCD 0102h was
  436.      interpreted as 1.02, which is incorrect.
  437.  
  438.      The OemStringPtr is a Real Mode far pointer to a null terminated OEM-
  439.      defined string. This string may be used to identify the graphics
  440.      controller chip or OEM product family for hardware specific display
  441.      drivers. There are no restrictions on the format of the string.  This
  442.      pointer may point into either ROM or RAM, depending on the specific
  443.      implementation.  VBE 2.0 BIOS implementations must place this string
  444.      in the OemData area within the VbeInfoBlock if 'VBE2' is preset in the
  445.      VbeSignature field on entry to Function 00h.  This makes it possible
  446.      to convert the RealMode address to an offset within the VbeInfoBlock
  447.      for Protected mode applications.
  448.  
  449.      Note: The length of the OEMString is not defined, but for space
  450.      considerations, we recommend a string length of less than 256 bytes.
  451.  
  452.      The Capabilities field indicates the support of specific features in
  453.      the graphics environment. The bits are defined as follows:
  454.  
  455.      D0     = 0     DAC is fixed width, with 6 bits per primary color
  456.             = 1     DAC width is switchable to 8 bits per primary color
  457.      D1     = 0     Controller is VGA compatible
  458.             = 1     Controller is not VGA compatible
  459.      D2     = 0     Normal RAMDAC operation
  460.             = 1     When programming large blocks of information to the
  461.                     RAMDAC use blank bit in Function 09h. i.e. RAMDAC
  462.                     recommends programming during blank period only.
  463.      D3-31  = Reserved
  464.  
  465.      BIOS Implementation Note: The DAC must always be restored to 6 bits
  466.      per primary as default upon a mode set.  If the DAC has been switched
  467.      to 8 bits per primary, the mode set must restore the DAC to 6 bits per
  468.      primary to ensure the application developer that he does not have to
  469.      reset it.
  470.  
  471.      Application Developer's Note:  If a DAC is switchable, you can assume
  472.      that the DAC will be restored to 6 bits per primary upon a mode set.
  473.      For an application to use a DAC the application program is responsible
  474.      for setting the DAC to 8 bits per primary mode using Function 08h.
  475.  
  476.      VGA compatibility is defined as supporting all standard IBM VGA modes,
  477.      fonts and I/O ports; however, VGA compatibility doesn't guarantee that
  478.      all modes which can be set are VGA compatible, or that the 8x14 font
  479.      is available.
  480.  
  481.      The need for D2 = 1 "program the RAMDAC using the blank bit in
  482.      Function 09h" is for older style RAMDAC's where programming the RAM
  483.      values during display time causes a "snow-like" effect on the screen.
  484.      Newer style RAMDAC's don't have this limitation and can easily be
  485.      programmed at any time, but older RAMDAC's require the that they be
  486.      blanked so as not to display the snow while values change during
  487.      display time..  This bit informs the software that they should make
  488.      the function call with 80h rather than 00h to ensure the minimization
  489.      of the "snow-like" effect.
  490.  
  491.      The VideoModePtr points to a list of  mode numbers for all  display
  492.      modes supported by the VBE implementation.  Each mode number occupies
  493.      one word (16 bits). The list of mode numbers is terminated by a -1
  494.      (0FFFFh).  The mode numbers in this list represent all of the
  495.      potentially supported modes by the display controller.  Please refer
  496.      to Chapter 3 for a description of VESA VBE mode numbers.  VBE 2.0 BIOS
  497.      implementations must place this mode list in the Reserved area in the
  498.      VbeInfoBlock or have it statically stored within the VBE
  499.      implementation if 'VBE2' is preset in the VbeSignature field on entry
  500.      to Function 00h.
  501.  
  502.      Note: It is the application's responsibility to verify the actual
  503.      availability of any mode returned by this function through the Return
  504.      VBE Mode Information (VBE Function 01h) call. Some of the returned
  505.      modes may not be available due to the actual amount of memory
  506.      physically installed on the display board or due to the capabilities
  507.      of the attached monitor.
  508.  
  509.      Note: If a VideoModeList is found to contain no entries (starts with
  510.      0FFFFh), it can be assumed that the VBE implementation is a "stub"
  511.      implementation where only Function 00h is supported for diagnostic or
  512.      "Plug and Play" reasons.  These stub implementations are not VBE 2.0
  513.      compliant and should only be implemented in cases where no space is
  514.      available to implement the whole VBE.
  515.  
  516.      The TotalMemory field indicates the maximum amount of memory
  517.      physically installed and available to the frame buffer in 64KB units.
  518.      (e.g. 256KB = 4, 512KB = 8)  Not all video modes can address all this
  519.      memory, see the ModeInfoBlock for detailed information about the
  520.      addressible memory for a given mode.
  521.  
  522.      The OemSoftwareRev field is a BCD value which specifies the OEM
  523.      revision level of the VBE software.  The higher byte specifies the
  524.      major version number. The lower byte specifies the minor version
  525.      number.  This field can be used to identify the OEM's VBE software
  526.      release.  This field is only filled in when 'VBE2' is preset in the
  527.      VbeSignature field on entry to Function 00h.
  528.  
  529.      The OemVendorNamePtr is a pointer to  a null-terminated string
  530.      containing the name of the vendor who produced the display controller
  531.      board product.  (This string may be contained in the VbeInfoBlock or
  532.      the VBE implementation.)  This field is only filled in when 'VBE2' is
  533.      preset in the VbeSignature field on entry to Function 00h.  (Note:
  534.      the length of the strings OemProductRev, OemProductName and
  535.      OemVendorName (including terminators) summed, must fit within a 256
  536.      byte buffer; this is to allow for return in the OemData field if
  537.      necessary.)
  538.  
  539.      The OemProductNamePtr is a pointer to  a null-terminated string
  540.      containing the product name of the display controller board.  (This
  541.      string may be contained in the VbeInfoBlock or the VBE
  542.      implementation.)  This field is only filled in when 'VBE2' is preset
  543.      in the VbeSignature field on entry to Function 00h.  (Note:  the
  544.      length of the strings OemProductRev, OemProductName and OemVendorName
  545.      (including terminators) summed, must fit within a 256 byte buffer;
  546.      this is to allow for return in the OemData field if necessary.)
  547.  
  548.      The OemProductRevPtr is a pointer to a null-terminated string
  549.      containing the revision or manufacturing level of the display
  550.      controller board product.  (This string may be contained in the
  551.      VbeInfoBlock or the VBE implementation.)  This field can be used to
  552.      determine which production revision of the display controller board is
  553.      installed.  This field is only filled in when 'VBE2' is preset in the
  554.      VbeSignature field on entry to Function 00h.  (Note:  the length of
  555.      the strings OemProductRev, OemProductName and OemVendorName (including
  556.      terminators) summed, must fit within a 256 byte buffer; this is to
  557.      allow for return in the OemData field if necessary.)
  558.  
  559.      The Reserved field is a space reserved for dynamically building the
  560.      VideoModeList if necessary if the VideoModeList is not statically
  561.      stored within the VBE implementation.  This field should not be used
  562.      for anything else, and may be reassigned in the future.  Application
  563.      software should not assume that information in this field is valid.
  564.  
  565.      The OemData field is a 256 byte data area that is used to return OEM
  566.      information returned by VBE Function 00h when 'VBE2' is preset in the
  567.      VbeSignature field.  The OemVendorName string, OemProductName string
  568.      and OemProductRev string are copied into this area by the VBE
  569.      implementation.  This area will only be used by VBE implementations
  570.      2.0 and above when 'VBE2' is preset in the VbeSignature field.
  571.      4.4. Function 01h - Return VBE Mode Information
  572.  
  573.      This required function returns extended information about a specific
  574.      VBE display mode from the mode list returned by VBE Function 00h.
  575.      This function fills the mode information block, ModeInfoBlock,
  576.      structure with technical details on the requested mode.  The
  577.      ModeInfoBlock structure is provided by the application with a fixed
  578.      size of 256 bytes.
  579.  
  580.      Information can be obtained for all listed modes in the Video Mode
  581.      List returned in Function 00h.  If the requested mode cannot be used
  582.      or is unavailable, a bit will be set in the ModeAttributes field to
  583.      indicate that the mode is not supported in the current configuration.
  584.  
  585.      Input:    AX   = 4F01h   Return VBE mode information
  586.                CX   =         Mode number
  587.             ES:DI   =         Pointer to ModeInfoBlock structure
  588.  
  589.      Output:   AX   =         VBE Return Status
  590.  
  591.      Note: All other registers are preserved.
  592.  
  593.      The mode information block has the following structure:
  594.  
  595.      ModeInfoBlock   struc
  596.  
  597.      ; Mandatory information for all VBE revisions
  598.      ModeAttributes      dw ?      ; mode attributes
  599.      WinAAttributes      db ?      ; window A attributes
  600.      WinBAttributes      db ?      ; window B attributes
  601.      WinGranularity      dw ?      ; window granularity
  602.      WinSize             dw ?      ; window size
  603.      WinASegment         dw ?      ; window A start segment
  604.      WinBSegment         dw ?      ; window B start segment
  605.      WinFuncPtr          dd ?      ; pointer to window function
  606.      BytesPerScanLine    dw ?      ; bytes per scan line
  607.  
  608.      ; Mandatory information for VBE 1.2 and above
  609.      XResolution         dw ?      ; horizontal resolution in pixels or chars
  610.      YResolution         dw ?      ; vertical resolution in pixels or chars
  611.      XCharSize           db ?      ; character cell width in pixels
  612.      YCharSize           db ?      ; character cell height in pixels
  613.      NumberOfPlanes      db ?      ; number of memory planes
  614.      BitsPerPixel        db ?      ; bits per pixel
  615.      NumberOfBanks       db ?      ; number of banks
  616.      MemoryModel         db ?      ; memory model type
  617.      BankSize            db ?      ; bank size in KB
  618.      NumberOfImagePages  db ?      ; number of images
  619.      Reserved            db ?      ; reserved for page function
  620.  
  621.      ; Direct Color fields (required for direct/6 and YUV/7 memory models)
  622.      RedMaskSize         db ?      ; size of direct color red mask in bits
  623.      RedFieldPosition    db ?      ; bit position of lsb of red mask
  624.      GreenMaskSize       db ?      ; size of direct color green mask in bits
  625.      GreenFieldPosition  db ?      ; bit position of lsb of green mask
  626.      BlueMaskSize        db ?      ; size of direct color blue mask in bits
  627.      BlueFieldPosition   db ?      ; bit position of lsb of blue mask
  628.      RsvdMaskSize        db ?      ; size of direct color reserved mask in bits
  629.      RsvdFieldPosition   db ?      ; bit position of lsb of reserved mask
  630.      DirectColorModeInfo db ?      ; direct color mode attributes
  631.  
  632.      ; Mandatory information for VBE 2.0 and above
  633.      PhysBasePtr         dd ?      ; physical address for flat frame buffer
  634.      OffScreenMemOffset  dd ?      ; pointer to start of off screen memory
  635.      OffScreenMemSize    dw ?      ; amount of off screen memory in 1k units
  636.      Reserved            db 206 dup (?)  ; remainder of ModeInfoBlock
  637.      ModeInfoBlock ends
  638.  
  639.      The ModeAttributes field describes certain important characteristics
  640.      of the graphics mode.
  641.  
  642.      The ModeAttributes field is defined as follows:
  643.  
  644.      D0   =    Mode supported by hardware configuration
  645.           0 =  Mode not supported in hardware
  646.           1 =  Mode supported in hardware
  647.      D1   =    1 (Reserved)
  648.      D2   =    TTY Output functions supported by BIOS
  649.           0 =  TTY Output functions not supported by BIOS
  650.           1 =  TTY Output functions supported by BIOS
  651.      D3   =    Monochrome/color mode (see note below)
  652.           0 =  Monochrome mode
  653.           1 =   Color mode
  654.      D4   =    Mode type
  655.           0 =  Text mode
  656.           1 =  Graphics mode
  657.      D5   =    VGA compatible mode
  658.           0 =  Yes
  659.           1 =  No
  660.      D6   =    VGA compatible windowed memory mode is available
  661.           0 =  Yes
  662.           1 =  No
  663.      D7   =    Linear frame buffer mode is available
  664.           0 =  No
  665.           1 =  Yes
  666.      D8-D15 =  Reserved
  667.  
  668.      Bit D0 is set to indicate that this mode can be initialized in the
  669.      present hardware configuration. This bit is reset to indicate the
  670.      unavailability of a graphics mode if it requires a certain monitor
  671.      type, more memory than is physically installed, etc.
  672.  
  673.      Bit D1 was used by VBE 1.0 and 1.1 to indicate that the optional
  674.      information following the BytesPerScanLine field were present in the
  675.      data structure.  This information became mandatory with VBE version
  676.      1.2 and above, so D1 is no longer used and should be set to 1.  The
  677.      Direct Color fields are valid only if the MemoryModel field is set to
  678.      a 6 (Direct Color) or 7 (YUV).
  679.      Bit D2 indicates whether the video BIOS has support for output
  680.      functions like TTY output, scroll, etc. in this mode.  TTY support is
  681.      recommended but not required for all extended text and graphic modes.
  682.      If bit D2 is set to 1, then the INT 10h BIOS must support all of the
  683.      standard output functions listed below.
  684.  
  685.      All of the following TTY functions must be supported when this bit is
  686.      set:
  687.  
  688.           01   Set Cursor Size
  689.           02   Set Cursor Position
  690.           06   Scroll TTY window up or Blank Window
  691.           07   Scroll TTY window down or Blank Window
  692.           09   Write character and attribute at cursor position
  693.           0A   Write character only at cursor position
  694.           0E   Write character and advance cursor  
  695.  
  696.      Bit D3 is set to indicate color modes, and cleared for monochrome
  697.      modes.
  698.  
  699.      Bit D4 is set to indicate graphics modes, and cleared for text modes.
  700.  
  701.      Note: Monochrome modes map their CRTC address at 3B4h. Color modes map
  702.      their CRTC address at 3D4h. Monochrome modes have attributes in which
  703.      only bit 3 (video) and bit 4 (intensity) of the attribute controller
  704.      output are significant. Therefore, monochrome text modes have
  705.      attributes of off, video, high intensity, blink, etc. Monochrome
  706.      graphics modes are two plane graphics modes and have attributes of
  707.      off, video, high intensity, and blink. Extended two color modes that
  708.      have their CRTC address at 3D4h, are color modes with one bit per
  709.      pixel and one plane. The standard VGA modes, 06h and 11h would be
  710.      classified as color modes, while the standard VGA modes 07h and 0Fh
  711.      would be classified as monochrome modes.
  712.  
  713.      Bit D5 is used to indicate if the mode is compatible with the VGA
  714.      hardware registers and I/O ports.  If this bit is set, then the mode
  715.      is NOT VGA compatible and no assumptions should be made about the
  716.      availability of any VGA registers.   If clear, then the standard VGA
  717.      I/O ports and frame buffer address defined in WinASegment and/or
  718.      WinBSegment can be assumed.
  719.  
  720.      Bit D6 is used to indicate if the mode provides Windowing or Banking
  721.      of the frame buffer into the frame buffer memory region specified by
  722.      WinASegment and WinBSegment.  If set, then Windowing of the frame
  723.      buffer is NOT possible.  If clear, then the device is capable of
  724.      mapping the frame buffer into the segment specified in WinASegment
  725.      and/or WinBSegment.  (This bit is used in conjunction with bit D7, see
  726.      table following D7 for usage)
  727.  
  728.      Bit D7 indicates the presence of a Linear Frame Buffer memory model.
  729.      If this bit is set, the display controller can be put into a flat
  730.      memory model by setting the mode (VBE Function 02h) with the Flat
  731.      Memory Model bit set. (This bit is used in conjunction with bit D6,
  732.      see following table for usage)
  733.  
  734.                       +-----------+-----+-----+
  735.                       |           | D7  | D6  |
  736.                       +-----------+-----+-----+
  737.                       |  Windowed |  0  |  0  |
  738.                       |   frame   |     |     |
  739.                       |   buffer  |     |     |
  740.                       |    only   |     |     |
  741.                       +-----------+-----+-----+
  742.                       |    n/a    |  0  |  1  |
  743.                       +-----------+-----+-----+
  744.                       |    Both   |  1  |  0  |
  745.                       |  Windowed |     |     |
  746.                       |    and 4  |     |     |
  747.                       |  Linear   |     |     |
  748.                       +-----------+-----+-----+
  749.                       |   Linear  |  1  |  1  |
  750.                       |   frame   |     |     |
  751.                       |   buffer  |     |     |
  752.                       |    only   |     |     |
  753.                       +-----------+-----+-----+
  754.  
  755.  
  756.      The BytesPerScanLine field specifies how many full bytes are in each
  757.      logical scanline. The logical scanline could be equal to or larger
  758.      than the displayed scanline.
  759.  
  760.      The WinAAttributes and WinBAttributes describe the characteristics of
  761.      the CPU windowing scheme such as whether the windows exist and are
  762.      read/writeable, as follows:
  763.  
  764.      D0    =    Relocatable window(s) supported
  765.            0 =  Single non-relocatable window only
  766.            1 =  Relocatable window(s) are supported
  767.      D1    =    Window readable
  768.            0 =  Window is not readable
  769.            1 =  Window is readable
  770.      D2    =    Window writeable
  771.            0 =  Window is not writeable
  772.            1 =  Window is writeable
  773.      D3-D7 =    Reserved
  774.  
  775.      Even if windowing is not supported, (bit D0 = 0 for both Window A and
  776.      Window B), then an application can assume that the display memory
  777.      buffer resides at the location specified by WinASegment and/or
  778.      WinBSegment.
  779.  
  780.      WinGranularity specifies the smallest boundary, in KB, on which the
  781.      window can be placed in the frame buffer memory. The value of this
  782.      field is undefined if Bit D0 of the appropriate WinAttributes field is
  783.      not set.
  784.  
  785.      WinSize specifies the size of the window in KB.
  786.  
  787.      WinASegment and WinBSegment address specify the segment addresses
  788.      where the windows are located in the CPU address space.
  789.  
  790.      Use D14 of the Mode Number to select the Linear Buffer on a mode set
  791.      (Function 02h).
  792.  
  793.      WinFuncPtr specifies the segment:offset of the VBE memory windowing
  794.      function. The windowing function can be invoked either through VBE
  795.      Function 05h, or by calling the function directly. A direct call will
  796.      provide faster access to the hardware paging registers than using VBE
  797.      Function 05h, and is intended to be used by high performance
  798.      applications. If this field is NULL, then VBE Function 05h must be
  799.      used to set the memory window when paging is supported.  This direct
  800.      call method uses the same parameters as VBE Function 05h including AX
  801.      and for VBE 2.0 implementations will return the correct Return Status.
  802.      VBE 1.2 implementations and earlier, did not require the Return Status
  803.      information to be returned.  For more information on the direct call
  804.      method, see the notes in VBE Function 05h and the sample code in
  805.      Appendix 5.
  806.  
  807.      The XResolution and YResolution specify the width and height in pixel
  808.      elements or characters for this display mode. In graphics modes, these
  809.      fields indicate the number of horizontal and vertical pixels that may
  810.      be displayed. In text modes, these fields indicate the number of
  811.      horizontal and vertical character positions.  The number of pixel
  812.      positions for text modes may be calculated by multiplying the returned
  813.      XResolution and YResolution values by the character cell width and
  814.      height indicated in the XCharSize and YCharSize fields described
  815.      below.
  816.  
  817.      The XCharSize and YCharSize specify the size of the character cell in
  818.      pixels.  (This value is not zero based)  e.g. XCharSize for Mode 3
  819.      using the 9 point font will have a value of 9.
  820.  
  821.      The NumberOfPlanes field specifies the number of memory planes
  822.      available to software in that mode. For standard 16-color VGA
  823.      graphics, this would be set to 4. For standard packed pixel modes, the
  824.      field would be set to 1.  For 256-color non-chain-4 modes, where you
  825.      need to do banking to address all pixels this value should be set to
  826.      the number of banks required to get to all the pixels (typically this
  827.      will be 4 or 8).
  828.  
  829.      The BitsPerPixel field specifies the total number of bits allocated to
  830.      one pixel. For example, a standard VGA 4 Plane 16-color graphics mode
  831.      would have a 4 in this field and a packed pixel 256-color graphics
  832.      mode would specify 8 in this field. The number of bits per pixel per
  833.      plane can normally be derived by dividing the BitsPerPixel field by
  834.      the NumberOfPlanes field.
  835.  
  836.      The MemoryModel field specifies the general type of memory
  837.      organization used in this mode. The following models have been
  838.      defined:
  839.  
  840.      00h  =    Text mode
  841.      01h  =    CGA graphics
  842.      02h  =    Hercules graphics
  843.      03h  =    Planar
  844.      04h  =    Packed pixel
  845.      05h  =    Non-chain 4, 256 color
  846.      06h  =    Direct Color
  847.      07h  =    YUV
  848.      08h-0Fh =      Reserved, to be defined by VESA
  849.      10h-FFh =      To be defined by OEM
  850.  
  851.      VBE Version 1.1 and earlier defined Direct Color graphics modes with
  852.      pixel formats 1:5:5:5, 8:8:8, and 8:8:8:8  as a Packed Pixel model
  853.      with 16, 24, and 32 bits per pixel, respectively. In VBE Version 1.2
  854.      and later, the Direct Color modes use the Direct Color memory model
  855.      and use the MaskSize and FieldPosition fields of the ModeInfoBlock to
  856.      describe the pixel format. BitsPerPixel is always defined to be the
  857.      total memory size of the pixel, in bits.
  858.  
  859.      NumberOfBanks. This is the number of banks in which the scan lines are
  860.      grouped. The quotient from dividing the scan line number by the number
  861.      of banks is the bank that contains the scan line and the remainder is
  862.      the scan line number within the bank. For example, CGA graphics modes
  863.      have two banks and Hercules graphics mode has four banks. For modes
  864.      that don't have scanline banks (such as VGA modes 0Dh-13h), this field
  865.      should be set to 1.
  866.  
  867.      The BankSize field specifies the size of a bank (group of scan lines)
  868.      in units of 1 KB. For CGA and Hercules graphics modes this is 8, as
  869.      each bank is 8192 bytes in length. For modes that don't have scanline
  870.      banks (such as VGA modes 0Dh-13h), this field should be set to 0.
  871.  
  872.      The NumberOfImagePages field specifies the "total number minus one (-
  873.      1)"of complete display images that will fit into the frame buffer
  874.      memory. The application may load more than one image into the frame
  875.      buffer memory if this field is non-zero, and move the display window
  876.      within each of those pages.  This should only be used for determining
  877.      the additional display pages which are available to the application;
  878.      to determine the available off screen memory, use the
  879.      OffScreenMemOffset and OffScreenMemSize information.
  880.  
  881.      Note: If the ModeInfoBlock is for an IBM Standard VGA mode and the
  882.      NumberOfImagePages field contains more pages than would be found in a
  883.      256KB implementation, the TTY support described in the ModeAttributes
  884.      must be accurate.  i.e. if the TTY functions are claimed to be
  885.      supported, they must be supported in all pages, not just the pages
  886.      normally found in the 256KB implementation.
  887.  
  888.      The Reserved field has been defined to support a future VBE feature
  889.      and will always be set to one in this version.
  890.  
  891.      The RedMaskSize, GreenMaskSize, BlueMaskSize, and RsvdMaskSize fields
  892.      define the size, in bits, of the red, green, and blue components of a
  893.      direct color pixel. A bit mask can be constructed from the MaskSize
  894.      fields using simple shift arithmetic. For example, the MaskSize values
  895.      for a Direct Color 5:6:5 mode would be 5, 6, 5, and 0, for the red,
  896.      green, blue, and reserved fields, respectively. Note that in the YUV
  897.      MemoryModel, the red field is used for V, the green field is used for
  898.      Y, and the blue field is used for U. The MaskSize fields should be set
  899.      to 0 in modes using a memory model that does not have pixels with
  900.      component fields.
  901.  
  902.      The RedFieldPosition, GreenFieldPosition, BlueFieldPosition, and
  903.      RsvdFieldPosition fields define the bit position within the direct
  904.      color pixel or YUV pixel of the least significant bit of the
  905.      respective color component. A color value can be aligned with its
  906.      pixel field by shifting the value left by the FieldPosition. For
  907.      example, the FieldPosition values for a Direct Color 5:6:5 mode would
  908.      be 11, 5, 0, and 0, for the red, green, blue, and reserved fields,
  909.      respectively. Note that in the YUV MemoryModel, the red field is used
  910.      for V, the green field is used for Y, and the blue field is used for
  911.      U. The FieldPosition fields should be set to 0 in modes using a memory
  912.      model that does not have pixels with component fields.
  913.  
  914.      The DirectColorModeInfo field describes important characteristics of
  915.      direct color modes.  Bit D0 specifies whether the color ramp of the
  916.      DAC is fixed or programmable. If the color ramp is fixed, then it can
  917.      not be changed. If the color ramp is programmable, it is assumed that
  918.      the red, green, and blue lookup tables can be loaded by using VBE
  919.      Function 09h.  Bit D1 specifies whether the bits in the Rsvd field of
  920.      the direct color pixel can be used by the application or are reserved,
  921.      and thus unusable.
  922.  
  923.      D0   =    Color ramp is fixed/programmable
  924.           0 =  Color ramp is fixed
  925.           1 =  Color ramp is programmable
  926.      D1   =    Bits in Rsvd field are usable/reserved
  927.           0 =  Bits in Rsvd field are reserved
  928.           1 =  Bits in Rsvd field are usable by the application
  929.  
  930.      The PhysBasePtr is a 32 bit physical address of the start of frame
  931.      buffer memory when the controller is in flat frame buffer memory mode.
  932.      If this mode is not available, then this field will be zero.
  933.  
  934.      The OffScreenMemOffset is a 32 bit offset from the start of the frame
  935.      buffer memory.  Extra off-screen memory that is needed by the
  936.      controller may be located either before or after this off screen
  937.      memory, be sure to check OffScreenMemSize to determine the amount of
  938.      off-screen memory which is available to the application.
  939.  
  940.      The OffScreenMemSize contains the amount of available, contiguous off-
  941.      screen memory in 1k units, which can be used by the application.
  942.  
  943.      Note: Version 1.1 and later VBE will zero out all unused fields in the
  944.      Mode Information Block, always returning exactly 256 bytes. This
  945.      facilitates upward compatibility with future versions of the standard,
  946.      as any newly added fields will be designed such that values of zero
  947.      will indicate nominal defaults or non-implementation of optional
  948.      features. (For example, a field containing a bit-mask of extended
  949.      capabilities would reflect the absence of all such capabilities.)
  950.      Applications that wish to be backwards compatible to Version 1.0 VBE
  951.      should pre-initialize the 256 byte buffer before calling the Return
  952.      VBE Mode Information function.
  953.  
  954.      4.5. Function 02h  - Set VBE Mode
  955.  
  956.      This required function initializes the controller and sets a VBE mode.
  957.      The format of VESA VBE mode numbers is described earlier in this
  958.      document. If the mode cannot be set, the BIOS should leave the
  959.      graphics environment unchanged and return a failure error code.
  960.  
  961.      Input:    AX   = 4F02h     Set VBE Mode
  962.                BX   =           Desired Mode to set
  963.                     D0-D8  =    Mode number
  964.                     D9-D13 =    Reserved (must be 0)
  965.                     D14    = 0  Use windowed frame buffer model
  966.                            = 1  Use linear/flat frame buffer model
  967.                     D15    = 0  Clear display memory
  968.                            = 1  Don't clear display memory
  969.  
  970.      Output:   AX   =           VBE Return Status
  971.  
  972.      Note: All other registers are preserved.
  973.  
  974.      If the requested mode number is not available, then the call will
  975.      fail, returning AH=01h to indicate the failure to the application.
  976.  
  977.      If bit D14 is set, the mode will be initialized for use with a flat
  978.      frame buffer model.  The base address of the frame buffer can be
  979.      determined from the extended mode information returned by VBE Function
  980.      01h.  If D14 is set, and a linear frame buffer model is not available
  981.      then the call will fail, returning AH=01h to the application.
  982.  
  983.      If bit D15 is not set, all reported image pages, based on Function 00h
  984.      returned information NumberOfImagePages, will be cleared to 00h in
  985.      graphics mode, and 20 07 in text mode.  Memory over and above the
  986.      reported image pages will not be changed.  If bit D15 is set, then the
  987.      contents of the frame buffer after the mode change is undefined.
  988.      Note, the 1-byte mode numbers used in Function 00h of an IBM VGA
  989.      compatible BIOS use D7 to signify the same thing as D15 does in this
  990.      function.  If D7 is set for an IBM compatible mode set using this
  991.      Function (02), this mode set will fail.  VBE aware applications must
  992.      use the memory clear bit in D15.
  993.  
  994.      Note: VBE BIOS 2.0 implementations should also update the BIOS Data
  995.      Area 40:87 memory clear bit so that VBE Function 03h can return this
  996.      flag. VBE BIOS 1.2 and earlier implementations ignore the memory clear
  997.      bit.
  998.  
  999.      Note:  This call should not set modes not listed in the list of
  1000.      supported modes.  In addition all modes (including IBM standard VGA
  1001.      modes), if listed as supported, must have ModeInfoBlock structures
  1002.      associated with them.  Required ModeInfoBlock values for the IBM
  1003.      Standard Modes are listed in Appendix 2.
  1004.  
  1005.      Note: If there is a failure when selecting an unsupported D14 value,
  1006.      the error return should be 02h.
  1007.  
  1008.      4.6. Function 03h - Return current VBE Mode
  1009.  
  1010.      This required function returns the current VBE mode. The format of VBE
  1011.      mode numbers is described earlier in this document.
  1012.  
  1013.      Input:    AX   = 4F03h   Return current VBE Mode
  1014.  
  1015.      Output:   AX   =         VBE Return Status
  1016.                BX   =         Current VBE mode
  1017.                     D0-D13 =  Mode number
  1018.                     D14  = 0  Windowed frame buffer model
  1019.                          = 1  Linear/flat frame buffer model
  1020.                     D15  = 0  Memory cleared at last mode set
  1021.                          = 1  Memory not cleared at last mode set
  1022.  
  1023.      Note: All other registers are preserved.
  1024.  
  1025.      Version 1.x Note: In a standard VGA BIOS, Function 0Fh (Read current
  1026.      video state) returns the current graphics mode in the AL register. In
  1027.      D7 of AL, it also returns the status of the memory clear bit (D7 of
  1028.      40:87). This bit is set if the mode was set without clearing memory.
  1029.      In this VBE function, the memory clear bit will not be returned in BX
  1030.      since the purpose of the function is to return the video mode only. If
  1031.      an application wants to obtain the memory clear bit, it should call
  1032.      the standard VGA BIOS Function 0Fh.
  1033.  
  1034.      Version 2.x Note:  Unlike version 1.x VBE implementations, the memory
  1035.      clear flag will be returned.  The application should NOT call the
  1036.      standard VGA BIOS Function 0Fh if the mode was set with VBE Function
  1037.      02h.
  1038.  
  1039.      Note: The mode number returned must be the same mode number used in
  1040.      the VBE Function 02h mode set.
  1041.  
  1042.      Note: This function is not guaranteed to return an accurate mode value
  1043.      if the mode set was not done with VBE Function 02h.
  1044.  
  1045.      4.7. Function 04h  - Save/Restore state
  1046.  
  1047.      This required function provides a complete mechanism to save and
  1048.      restore the display controller hardware state. The functions are a
  1049.      superset of the three subfunctions under the standard VGA BIOS
  1050.      Function 1Ch (Save/restore state) which does not guarantee that the
  1051.      extended registers of the video device are saved or restored. The
  1052.      complete hardware state (except frame buffer memory) should be
  1053.      saveable/restorable by setting the requested states mask (in the CX
  1054.      register) to 000Fh.
  1055.  
  1056.      Input:    AX   = 4F04h   Save/Restore state
  1057.                DL   = 00h         Return save/restore state buffer size
  1058.                     = 01h         Save state
  1059.                     = 02h         Restore state
  1060.                CX   =         Requested states
  1061.                     D0=           Save/restore controller hardware state
  1062.                     D1=           Save/restore BIOS data state
  1063.                     D2=           Save/restore DAC state
  1064.                     D3=           Save/restore Register state
  1065.                ES:BX=         Pointer to buffer  (if DL <> 00h)
  1066.  
  1067.      Output:   AX   =         VBE Return Status
  1068.                BX   =         Number of 64-byte blocks to hold the state
  1069.                               buffer  (if DL=00h)
  1070.  
  1071.      Note: All other registers are preserved.
  1072.  
  1073.      4.8. Function 05h - Display Window Control
  1074.  
  1075.      This required function sets or gets the position of the specified
  1076.      display window or page in the frame buffer memory by adjusting the
  1077.      necessary hardware paging registers.  To use this function properly,
  1078.      the software should first use VBE Function 01h (Return VBE Mode
  1079.      information) to determine the size, location and granularity of the
  1080.      windows.
  1081.  
  1082.      For performance reasons, it may be more efficient to call this
  1083.      function directly, without incurring the INT 10h overhead.  VBE
  1084.      Function 01h returns the segment:offset of this windowing function
  1085.      that may be called directly for this reason.  Note that a different
  1086.      entry point may be returned based upon the selected mode.  Therefore,
  1087.      it is necessary to retrieve this segment:offset specifically for each
  1088.      desired mode.
  1089.  
  1090.      Input:    AX   = 4F05h   VBE Display Window Control
  1091.                BH   = 00h          Set memory window
  1092.                     = 01h          Get memory window
  1093.                BL   =         Window number
  1094.                     = 00h          Window A
  1095.                     = 01h          Window B
  1096.                DX   =         Window number in video memory in window
  1097.                               granularity units  (Set Memory Window only)
  1098.  
  1099.      Output:   AX   =         VBE Return Status
  1100.                DX   =         Window number in window granularity units
  1101.                                    (Get Memory Window only)
  1102.  
  1103.      Note: In VBE 1.2 implementations, the direct far call version returns
  1104.      no Return Status information to the application. Also, in the far call
  1105.      version, the AX and DX registers will be destroyed. Therefore if AX
  1106.      and/or DX must be preserved, the application must do so prior to
  1107.      making the far call.  The application must still load the input
  1108.      arguments in BH, BL, and DX (for Set Window).  In VBE 2.0
  1109.      implementations, the BIOS will return the correct Return Status, and
  1110.      therefore the application must assume that AX and DX will be
  1111.      destroyed.
  1112.  
  1113.      Application Developer's Note:  This function is not intended for use
  1114.      in a linear frame buffer mode, if this function is requested, the
  1115.      function call will fail with the VBE Completion code AH=03h.
  1116.  
  1117.      VBE BIOS Implementation Note:  If this function is called while in a
  1118.      linear frame buffer memory model, this function must fail with
  1119.      completion code AH=03h.
  1120.  
  1121.      4.9. Function 06h - Set/Get Logical Scan Line Length
  1122.  
  1123.      This required function sets or gets the length of a logical scan line.
  1124.      This allows an application to set up a logical display memory buffer
  1125.      that is wider than the displayed area. VBE Function 07h (Set/Get
  1126.      Display Start) then allows the application to set the starting
  1127.      position that is to be displayed.
  1128.  
  1129.      Input:    AX   = 4F06h   VBE Set/Get Logical Scan Line Length
  1130.                BL   = 00h          Set Scan Line Length in Pixels
  1131.                     = 01h          Get Scan Line Length
  1132.                     = 02h          Set Scan Line Length in Bytes
  1133.                     = 03h          Get Maximum Scan Line Length
  1134.                CX   =         If BL=00h  Desired Width in Pixels
  1135.                               If BL=02h  Desired Width in Bytes
  1136.                               (Ignored for Get Functions)
  1137.  
  1138.      Output:   AX   =         VBE Return Status
  1139.                BX   =         Bytes Per Scan Line
  1140.                CX   =         Actual Pixels Per Scan Line
  1141.                               (truncated to nearest complete pixel)
  1142.                DX   =         Maximum Number of Scan Lines
  1143.  
  1144.      Note: The desired width in pixels or bytes may not be achievable
  1145.      because of hardware considerations.  The next larger value will be
  1146.      selected that will accommodate the desired number of pixels or bytes,
  1147.      and the actual number of pixels will be returned in CX. BX returns a
  1148.      value that when added to a pointer into display memory will point to
  1149.      the next scan line. For example, in VGA mode 13h this would be 320,
  1150.      but in mode 12h this would be 80.  DX returns the number of logical
  1151.      scan lines based upon the new scan line length and the total memory
  1152.      installed and usable in this display mode.
  1153.  
  1154.      Note: This function is also valid in text modes.   In text modes the
  1155.      application should convert the character line length to pixel line
  1156.      length by getting the current character cell width through the
  1157.      XCharSize field returned in ModeInfoBlock, multiplying that times the
  1158.      desired number of characters per line, and passing that value in the
  1159.      CX register.  In addition, this function will only work if the line
  1160.      length is specified in character granularity.  i.e. in 8 dot modes
  1161.      only multiples of 8 will work.  Any value which is not in character
  1162.      granularity will result in a function call failure.
  1163.  
  1164.      Note: On a failure to set scan line length by setting a CX value too
  1165.      large, the function will fail with error code 02h.
  1166.  
  1167.      Note: The value returned when BL=03h is the lesser of either the
  1168.      maximum line length that the hardware can support, or the longest scan
  1169.      line length that would support the number of lines in the current
  1170.      video mode.
  1171.  
  1172.      4.10.     Function 07h - Set/Get Display Start
  1173.  
  1174.      This required function selects the pixel to be displayed in the upper
  1175.      left corner of the display.  This function can be used to pan and
  1176.      scroll around logical screens that are larger than the displayed
  1177.      screen.  This function can also be used to rapidly switch between two
  1178.      different displayed screens for double buffered animation effects.
  1179.  
  1180.      Input:    AX   = 4F07h   VBE Set/Get Display Start Control
  1181.                BH   = 00h          Reserved and must be 00h
  1182.                BL   = 00h          Set Display Start
  1183.                     = 01h          Get Display Start
  1184.                     = 80h          Set Display Start during Vertical
  1185.      Retrace
  1186.                CX   =         First Displayed Pixel In Scan Line
  1187.                               (Set Display Start only)
  1188.                DX   =         First Displayed Scan Line (Set Display Start
  1189.      only)
  1190.  
  1191.      Output:   AX   =         VBE Return Status
  1192.                BH   =         00h Reserved and will be 0 (Get Display Start
  1193.      only)
  1194.                CX   =         First Displayed Pixel In Scan Line (Get Display
  1195.                               Start only)
  1196.                DX   =         First Displayed Scan Line (Get Display
  1197.                               Start only)
  1198.  
  1199.      Note:  This function is also valid in text modes.  To use this
  1200.      function in text mode, the application should convert the character
  1201.      coordinates to pixel coordinates by using XCharSize and YCharSize
  1202.      returned in the ModeInfoBlock.  If the requested Display Start
  1203.      coordinates do not allow for a full page of video memory or the
  1204.      hardware does not support memory wrapping, the Function call should
  1205.      fail and no changes should be made.  As a general case, if a requested
  1206.      Display Start is not available, fail the Function call and make no
  1207.      changes.
  1208.  
  1209.      4.11.     Function 08h - Set/Get DAC Palette Format
  1210.  
  1211.      This required function manipulates the operating mode or format of the
  1212.      DAC palette. Some DACs are configurable to provide 6 bits, 8 bits, or
  1213.      more of color definition per red, green, and blue primary colors.
  1214.      The DAC palette width is assumed to be reset to the standard VGA value
  1215.      of 6 bits per primary color during any mode set
  1216.  
  1217.      Input:    AX   = 4F08h   VBE Set/Get Palette Format
  1218.                BL   = 00h          Set DAC Palette Format
  1219.                     = 01h          Get DAC Palette Format
  1220.                BH   =         Desired bits of color per primary
  1221.                               (Set DAC Palette Format only)
  1222.  
  1223.      Output:   AX   =         VBE Return Status
  1224.                BH   =         Current number of bits of color per primary
  1225.  
  1226.      An application can determine if DAC switching is available by querying
  1227.      Bit D0 of the Capabilities field of the VbeInfoBlock structure
  1228.      returned by VBE Function 00h (Return Controller Information). The
  1229.      application can then attempt to set the DAC palette width to the
  1230.      desired value. If the display controller hardware is not capable of
  1231.      selecting the requested palette width, then the next lower value that
  1232.      the hardware is capable of will be selected. The resulting palette
  1233.      width is returned.
  1234.  
  1235.      This function will return failure code AH=03h if called in a direct
  1236.      color or YUV mode.
  1237.  
  1238.      4.12.     Function 09h - Set/Get Palette Data
  1239.  
  1240.      This required function is very important for RAMDAC's which are larger
  1241.      than a standard VGA RAMDAC.  The standard INT 10h BIOS Palette
  1242.      function calls assume standard VGA ports and VGA palette widths.  This
  1243.      function offers a palette interface that is independent of the VGA
  1244.      assumptions.
  1245.  
  1246.  
  1247.      Input:    AX   = 4F09h   VBE Load/Unload Palette Data
  1248.                BL   = 00h          Set Palette Data
  1249.                     = 01h          Get Palette Data
  1250.                     = 02h          Set Secondary Palette Data
  1251.                     = 03h          Get Secondary Palette Data
  1252.                     = 80h          Set Palette Data during Vertical Retrace
  1253.                                 with Blank Bit on
  1254.                CX   =         Number of palette registers to update
  1255.                DX   =         First palette register to update
  1256.                ES:DI=         Table of palette values (see below for
  1257.      format)
  1258.  
  1259.      Output:   AX   =         VBE Return Status
  1260.  
  1261.      Format of Palette Values:   Alignment byte, Red byte, Green byte, Blue
  1262.      byte
  1263.  
  1264.      Note: The need for BL= 80h is for older style RAMDAC's where
  1265.      programming the RAM values during display time causes a "snow-like"
  1266.      effect on the screen.  Newer style RAMDAC's don't have this limitation
  1267.      and can easily be programmed at any time, but older RAMDAC's require
  1268.      that they be programmed during a non-display time only to stop the
  1269.      snow like effect seen when changing the DAC values.  When this is
  1270.      requested the VBE implementation will program the DAC with blanking
  1271.      on.  Check D2 of the Capabilities field returned by VBE Function 00h
  1272.      to determine if 80h should be used instead of 00h.
  1273.  
  1274.      Note: The need for the secondary palette is for anticipated future
  1275.      palette extensions, if a secondary palette does not exist in a
  1276.      implementation and these calls are made, the VBE implementation will
  1277.      return error code 02h.
  1278.  
  1279.      Note:  When in 6 bit mode, the format of the 6 bits is LSB, this is
  1280.      done for speed reasons, as the application can typically shift the
  1281.      data faster than the BIOS can.
  1282.  
  1283.      Note: All application should assume the DAC is defaulted to 6 bit
  1284.      mode.  The application is responsible for switching the DAC to higher
  1285.      color modes using Function 08h.
  1286.  
  1287.      Note: Query VBE Function 08h to determine the RAMDAC width before
  1288.      loading a new palette.
  1289.  
  1290.      4.13.     Function 0Ah - Return VBE Protected Mode Interface
  1291.  
  1292.      This required function call returns a pointer to a table that contains
  1293.      code for a 32-bit protected mode interface that can either be copied
  1294.      into local 32 bit memory space or can be executed from ROM providing
  1295.      the calling application sets all required selectors and I/O access
  1296.      correctly. This function returns a pointer (in real mode space) with
  1297.      offsets to the code fragments, and additionally returns an offset to a
  1298.      table which contains Non-VGA Port and Memory locations which an
  1299.      Application may have to have I/O access to.
  1300.  
  1301.  
  1302.      Input:    AX   = 4F0Ah   VBE 2.0 Protected Mode Interface
  1303.                BL   = 00h          Return protected mode table
  1304.  
  1305.  
  1306.      Output:   AX   =         Status
  1307.                ES   =         Real Mode Segment of Table
  1308.                DI   =         Offset of Table
  1309.                CX   =         Length of Table including protected mode code
  1310.                               (for copying purposes)
  1311.  
  1312.  
  1313.      The format of the table is as follows:
  1314.  
  1315.           ES:DI + 00h    Word Offset in table of Protected mode code for
  1316.                          Function 5 for Set Window Call
  1317.           ES:DI + 02h    Word Offset in table of Protected mode code for
  1318.                          Function 7 for set Display Start
  1319.           ES:DI + 04h    Word Offset in table of Protected mode code for
  1320.                          Function 9 for set Primary Palette data
  1321.           ES:DI + 06h    Word  Offset in table of Ports and Memory Locations
  1322.                          that the application may need I/O privilege for.
  1323.                          (Optional:  if unsupported this must be 0000h)
  1324.                          (See Sub-table for format)
  1325.           ES:DI + ?      Variable remainder of Table including Code
  1326.  
  1327.  
  1328.      The format of the Sub-Table (Ports and Memory locations)
  1329.  
  1330.           Port, Port, ... , Port, Terminate Port List with FF FF, Memory
  1331.           locations (4 bytes), Length (2 bytes), Terminate Memory List with
  1332.           FF FF.
  1333.  
  1334.      Example 1. For Port/Index combination 3DE/Fh and Memory locations
  1335.      DE800-DEA00h (length = 200h) the table would look like this:
  1336.           DE 03 DF 03 FF FF 00 E8 0D 00 00 02 FF FF
  1337.  
  1338.      Example 2. For only the ports it would look like:
  1339.           DE 03 DF 03 FF FF FF FF
  1340.  
  1341.      Example 3. For only the memory locations it would look like
  1342.           FF FF 00 E8 0D 00 00 02 FF FF
  1343.  
  1344.      Note:. All protected mode functions should end with a near RET (as
  1345.      opposed to FAR RET) to allow the application software to CALL the code
  1346.      from within the ROM.
  1347.  
  1348.      Note:  The Port and Memory location Sub-table does not include the
  1349.      Frame Buffer Memory location.  The Frame Buffer Memory location is
  1350.      contained within the ModeInfoBlock returned by VBE Function 01h.
  1351.  
  1352.      Note:  The protected mode code is assembled for a 32-bit code segment,
  1353.      when copying it, the application must copy the code to a 32-bit code
  1354.      segment.
  1355.  
  1356.      Note:  It is the application's responsibility to ensure that the
  1357.      selectors and segments are set up correctly.
  1358.  
  1359.      Note:  Currently undefined registers may be destroyed with the
  1360.      exception of ESI, EBP, DS and SS.
  1361.  
  1362.  
  1363.      Note:  Refer to Section 4.2 for information on protected mode
  1364.      considerations.
  1365.  
  1366. --------------------------  END OF DOCUMENT --------------------------------
  1367.  
  1368.